public class Main {
    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);

        // 读取马路长度和区域数量
        int l = scanner.nextInt();
        int m = scanner.nextInt();

        // 初始化树木存在状态，true表示有树
        boolean[] trees = new boolean[l + 1];
        for (int i = 0; i <= l; i++) {
            trees[i] = true;
        }

        // 标记需要移除的树木
        for (int i = 0; i < m; i++) {
            int start = scanner.nextInt();
            int end = scanner.nextInt();
            for (int j = start; j <= end; j++) {
                trees[j] = false;
            }
        }
        scanner.close();

        // 统计剩余树木
        int count = 0;
        for (boolean exists : trees) {
            if (exists) {
                count++;
            }
        }

        System.out.println(count);
    }
}